package com.tofindaway.hibernate.entity;

import java.util.HashSet;
import java.util.Set;

public class SqlTable {
	private Long id;
	private Long lockVersion;
	private String Dn;
	private String note;
	private Set<SqlTabOpr> sqlOprSet;

	public SqlTable(Long id, String dn) {
		super();
		this.id = id;
		Dn = dn;
	}

	public SqlTable() {
		super();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getLockVersion() {
		return lockVersion;
	}

	public void setLockVersion(Long lockVersion) {
		this.lockVersion = lockVersion;
	}

	public String getDn() {
		return Dn;
	}

	public void setDn(String dn) {
		Dn = dn;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public Set<SqlTabOpr> getSqlOprSet() {
		return sqlOprSet == null ? sqlOprSet = new HashSet<SqlTabOpr>() : sqlOprSet;
	}

	public void setSqlOprSet(Set<SqlTabOpr> sqlOprSet) {
		this.sqlOprSet = sqlOprSet;
	}

	public void addSqlOpr(SqlTabOpr sqlOpr) {
		sqlOpr.setSqlTable(this);
		getSqlOprSet().add(sqlOpr);
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SqlTable other = (SqlTable) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "SqlTable [id=" + id + ", lockVersion=" + lockVersion + ", Dn="
				+ Dn + ", note=" + note + ", sqlOprSet=" + sqlOprSet + "]";
	}

}
